<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary()->comment('用户ID');
            $table->string('name',64)->default('')->comment('姓名');
            $table->string('phone',16)->default('')->comment('手机号');
            $table->string('id_card',255)->default('')->comment('身份证号');
            $table->string('avatar_url',255)->default('')->comment('头像');
            $table->string('wechat_open_id',64)->default('')->comment('微信openid');
            $table->string('email')->nullable()->unique()->comment('用户邮箱');
            $table->string('province',255)->nullable()->comment('省');
            $table->string('city',255)->nullable()->comment('市');
            $table->string('area',255)->nullable()->comment('区');
            $table->string('address',255)->nullable()->comment('地址');
            $table->string('address_detail',255)->nullable()->comment('详细地址');
            $table->enum('create_group',['Y','N'])->default('N')->comment('创建群组权限');
            $table->timestamp('email_verified_at')->nullable();
            $table->string('role_code',64)->default('')->index('role');
            $table->string('password')->default('');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
